<template>
	<view>
		<!-- <view class="u-demo-block__content">
			<u--form labelPosition="left" ref="form1">
				<u-form-item label="快递单号" borderBottom ref="item1" labelWidth="120">
					<u--input v-model="numbers" border="none" placeholder="请输入手机号"></u--input>
				</u-form-item>
				<u-button type="primary" text="物流查询" customStyle="margin-top: 50px" @click="submit()"></u-button>
			</u--form>
			
		</view> -->

		<view class='title'>
			<text>快递查询</text>
		</view>
		<!-- 输入框 -->		
		<view>
			请输入快递单号：<input class='input' placeholder="请输入快递单号" v-model="postid" type='text' confirm-type="search" />
			<u-button  type="error" @tap="query">查询</u-button>
			<span>{{ expressInfo }}</span>
		</view>
		
		<!-- 信息展示,滚动视图显示,不滑动页面 -->
		<!-- <scroll-view>
			<view v-for="item in expressInfo">
				<view>
					<view>
						<text>【{{item.time}}】:</text>
					</view>
					<view>
						<text> {{item.context}}</text>
					</view>
				</view>
			</view>
		</scroll-view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// numbers:'',

				//查询接口
				queryUrl: "http://www.kuaidi100.com/query?type=zhongtong&temp=0.9021720216142217&postid=",
				postid: '', //输入的快递单号  2453554766201674631
				expressInfo: [],
			};
		},
		methods: {
			query: function(event) {
				console.log(event)
				console.log("开始查询");
				// console.log("获取input输入值:" + event.detail.value);
				// this.setData({ //赋值输入的快递单号
					// postid:event.detail.value
				// })
				//发送请求
				var that = this; //赋值this,解决数据赋值问题
				uni.request({
					url: this.queryUrl + this.postid,
					data: {},
					method: "GET",
					header: {
						'content-type': 'application/json' // 默认值
					},
					success(res) {
						console.log(res.data)
						// console.log("that.expressInfo",that.expressInfo)
						//此处this指wx.request,不能使用this
						// that.setData({
						// 	expressInfo: res.data.data
						// })
					}
				})
			}
			
			
		},
		
	}
</script>

<style lang="scss">
	.title {
		text-align: center;
		width: 100%;
		margin-top: 10px;
	}

	.input {
		margin-left: 35px;
		margin-top: 20px;
		border-radius: 4px;
		border: 1px solid #c8cccf;
		width: 80%;
		height: 35px;
		vertical-align: middle;
	}

	.item {
		width: 85%;
		margin-top: 25px;
		margin-left: 25px;
	}
</style>
